-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vite doesn't inline SVG assets #1197
Comments
Look like |
We don't want to use base64 with svg files. See here: https://css-tricks.com/probably-dont-base64-svg/ Basically, base64 is larger in size, and svg files don't need it to be inlined. In fact, svg files even compress better without base64, because there's more repetition. If svg files aren't inlined currently, they should be. Just without base64. |
@aleclarson Thanks for yor clarify. |
Are there plans to support inlining svg without base64? |
Can you open a new issus to discuss it? |
Base64 is unnecessary for SVG files: https://github.com/vitejs/vite/issues/1197\#issuecomment-738780169 Also using `Buffer.byteLength` instead of character length when comparing with the `assetsInlineLimit` option.
Base64 is unnecessary for SVG files: https://github.com/vitejs/vite/issues/1197\#issuecomment-738780169 Also using `Buffer.byteLength` instead of character length when comparing with the `assetsInlineLimit` option.
"compress better without base64", everything does.... base64 is an encoding useful for content like binary which can't be represented in ASCII/UTF-8 text content, but has a drawback of 6 bits for every 8-bits, roughly 1.33x increase in weight. Inlining content via a base64 data URI still has it's benefits despite this. What you're referring to is inline SVG element, which isn't always appropriate (eg favicon). In some cases you need more accurate / crisp rendering and need the SVG content to be the You can workaround that by providing an integer width/height, but you must know that in advance and it comes with some other disadvantages if you want responsive content. Additionally the img element allows providing the |
vite/src/node/build/buildPluginAsset.ts
Lines 60 to 63 in 480367b
Hi. I noticed that
svg
files is explicitly excluded in theassetsInlineLimit
feature, and I'm wondering why that is so. Renaming the extension to.SVG
(thus bypassing the.endsWith
check) works fine in my project.This limit exists since the first time the feature was added, and I'm unable to find any kind of comments or documentation about it. Could someone shed some light on this please? Thanks!
The text was updated successfully, but these errors were encountered: